import subprocess

def RunScript(exe, script, *args):
    result = subprocess.run([exe, script, *args])
    if result.returncode != 0:
        print(f"Run {script} failed.")
    
    return result.returncode == 0

def main():
    print("\n***********fastdfs***********")
    RunScript('python3', './fastdfs.py', 'stop')
    RunScript('python3', './fastdfs.py', 'all')

    print("\n***********fastCGI***********")
    RunScript('python3', './fcgi.py', 'stop')
    RunScript('python3', './fcgi.py', 'start')

    print("\n************NGINX************")
    RunScript('python3', './nginx.py', 'stop')
    RunScript('python3', './nginx.py', 'start')

    print("\n************Redis************")
    RunScript('python3', './redis.py', 'stop')
    RunScript('python3', './redis.py', 'start')


if __name__ == '__main__':
    main()